import React, { Component } from 'react'
import './index.css'
import Item from '../Item'
import PropTypes from 'prop-types'

class List extends Component {

    static propTypes = {
        todoList: PropTypes.array.isRequired,
        upDateTodo: PropTypes.func.isRequired,
        deleteTodo: PropTypes.func.isRequired
    }

    render() {
        const {todoList, upDateTodo, deleteTodo} = this.props
        return (
            <ul className="todo-main">
                {todoList.map(todo => {
                    return <Item deleteTodo={deleteTodo} upDateTodo={upDateTodo} {...todo} key={todo.id}/>
                })}
            </ul>
        )
    }
}

export default List
